package com.zds.ftp.result;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.io.File;
import java.util.Date;

@Data
public class FileItem {
    private String name;
    private Boolean isDirectory;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastModified;
    public static FileItem of(File file) {
        return new FileItem(file.getName(), file.isDirectory(), file.lastModified());
    }

    public FileItem(String name, boolean isDirectory, long lastModified) {
        this.name = name;
        this.isDirectory = isDirectory;
        this.lastModified = new Date(lastModified);
    }
}
